﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using GalaSoft.MvvmLight.Messaging;
using SGTLightAccent.ViewModel;
using SGTLightAccent.Models;

namespace SGTLightAccent.Views
{
    public partial class NuevoClienteWindow : ChildWindow
    {
        public NuevoClienteWindow(string titulo)
        {
            InitializeComponent();
            this.Title = titulo;
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            EnvioMensaje txt = null;
            if (this.chkCrearUsuario.IsChecked.Value)
            {
                txt = new EnvioMensaje("CrearUsuario");
                txt.tag = this.contrasena.Password;
                if (chkPassReset.IsChecked.Value)
                    txt.texto = "ResetPass";
               

            }
            else
                txt = new EnvioMensaje("CrearClienteSinUsuario");
            Messenger.Default.Send<EnvioMensaje, MainViewModel>(txt);
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            if (this.contrasena == null)
                this.contrasena = new PasswordBox();
            if (this.confirmarContrasena == null)
                this.confirmarContrasena = new PasswordBox();
            this.contrasena.IsEnabled = true;
            this.confirmarContrasena.IsEnabled = true;
            this.txtCorreo.IsEnabled = true;
            this.txtUsuario.IsEnabled = true;
        }

        private void CheckBox_Unchecked(object sender, RoutedEventArgs e)
        {
            this.contrasena.IsEnabled = false;
            this.confirmarContrasena.IsEnabled = false;
            this.txtCorreo.IsEnabled = false;
            this.txtUsuario.IsEnabled = false;
        }
    }
}

